package org.aplombh.java.utils.multiThread.juc.unsafe;

import java.util.ArrayList;
import java.util.List;

public class UnsafeList {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<>();
        ThreadGroup myGroup = new ThreadGroup("myGroup");
        for (int i = 0; i < 100; i++) {
            new Thread(myGroup,() -> {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                list.add(Thread.currentThread().getName());
            }).start();
        }
        while (myGroup.activeCount() > 0)
            Thread.sleep(1000);
        System.out.println(list.size());
    }
}
